// store/index.js
import { configureStore } from "@reduxjs/toolkit";
import { persistStore, persistReducer } from "redux-persist";
import storage from "redux-persist/lib/storage";
import userReducer from "./modules/user";
import menus from "./modules/menus";
import images from "./modules/images";
// 用户模块持久化配置
const userPersistConfig = {
  key: "user",
  storage,
  whitelist: ["token", "userInfo", "isAuthenticated"], // 持久化这些字段
};

const persistedUserReducer = persistReducer(userPersistConfig, userReducer);

export const store = configureStore({
  reducer: {
    user: persistedUserReducer,
    menus: menus,
    images: images,
  },
  middleware: (getDefaultMiddleware) =>
    getDefaultMiddleware({
      serializableCheck: false, // 禁用序列化检查
    }),
});

export const persistor = persistStore(store);
